;;; init-go.el --- Go mode configuration -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

(defun ctrlwei/get-package-bin-path (package)
  "Return executable go package bin file location."
  (let ((package-bin-path (expand-file-name package "~/wspace/go/bin/")))
    (if (file-exists-p package-bin-path)
        package-bin-path
      package)))

(add-hook 'go-mode-hook #'lsp)
(with-eval-after-load 'go-mode
  (setq lsp-gopls-server-path (ctrlwei/get-package-bin-path "gopls"))
  (require 'lsp-go))

(with-eval-after-load 'go-ts-mode
  (require 'go-mode)
  (setq go-ts-mode-hook go-mode-hook)
  )

(provide 'init-go)
;;; init-go.el ends here
